package com.fivefaces.ide.plugins;

import com.fivefaces.ide.plugins.impl.*;

import java.io.IOException;

/**
 * User: abdullahkhan
 * Date: 13/09/12
 * Time: 10:15 PM
 */
public class ConsoleExecutablePathServiceFactory {
    private static ConsoleExecutablePathService instance;

    public static ConsoleExecutablePathService getInstance() throws IOException {
        if (instance == null) {
            String os = System.getProperty("os.name");

            if (os.startsWith("Windows")) {
                instance = new WindowsConsoleExecutablePathService();
            } else if (os.startsWith("Mac") || os.toLowerCase().contains("mac")) {
                instance = new MacConsoleExecutablePathService();
            } else if (os.startsWith("Linux") || os.toLowerCase().contains("linux")) {
                instance = new LinuxConsoleExecutablePathService();
            } else {
                throw new UnsupportedOperationException("Operating system - " + os + " not supported.");
            }
        }
        return instance;
    }
}
